import { execa } from 'execa'
import { g_pkg } from './utils.js'
import { existsSync } from 'node:fs'
import fs from 'node:fs/promises'

async function build(target) {
  const dfs = `${g_pkg.targetsDir}/${target}/dist`
  if (existsSync(dfs)) {
    await fs.rm(dfs, { recursive: true })
  }
  await execa('rollup',[
    '-cw',
    '--environment',
    `TARGET:${target},SOURCE_MAP:true`
  ], { stdio: 'inherit' })
}

build('reactivity')